<%@ page contentType= "text/html;charset=utf-8" %>

<html>
<%@ include file="../common/base.jsp" %>
<body>

<div id="container">
<%@ include file="../common/header.jsp" %>

	<div id="menu">
		<a href="<c:url value="/common/home.o"/>"><fmt:message key="Home" /></a> > 
	    <a href="<c:url value="/user/manage.o"/>"><fmt:message key="User" /></a> > 
	    <fmt:message key="${action}" />
	    <div  style="float: right" >
	    	<fmt:message key="Logged" />: <c:out value="${currentUser.username}" /> (<a href="<c:url value="/common/logout.o"/>"><fmt:message key="Logout" /></a>)
	    </div>
	</div>
	<div id="midbody">
	     <div id="leftside">
	     	<br>
		    <shiro:hasPermission name="user:manage">
	            <a href="<c:url value="/user/manage.o"/>"><fmt:message key="AllUser" /></a>
	            &nbsp;&nbsp;&nbsp;&nbsp;
	        </shiro:hasPermission>
		</div>
	      <div id="rightside">
	    	
	    <div id="bigbox">
	        <div class="title">
	        	<fmt:message key="${action}" /> <fmt:message key="User" />
	        	<%@ include file="../common/hidemenu.jsp" %>
	        </div>
	
	        <div class="content">
	        
	            <form:form modelAttribute="employee">
	                <form:errors path="*" element="div" cssClass="errors"/>
	                <div><div class="form-label"><fmt:message key="Username" />:</div><form:input path="username"/></div>
	                <div><div class="form-label"><fmt:message key="Email" />:</div><form:input path="email"/></div>
	                <div><div class="form-label"><fmt:message key="Serial" />:</div><form:input path="serial"/></div>
	                <div><div class="form-label"><fmt:message key="Tel" />:</div><form:input path="tel"/></div>
	                <div><div class="form-label"><fmt:message key="Password" />:</div><form:password path="password"/></div>
	                <div><div class="form-label"><fmt:message key="TestLightCode" />:</div><form:input path="testLightCode"/></div>
	                <div><div class="form-label"><fmt:message key="Roles" />:</div>&nbsp;</div>
	                <% int n = ((java.util.List)request.getAttribute("roles")).size(); %>
	                <% int index = 0; %>
	                <div>
	                	 <table>
		                	 <c:forEach var="role" varStatus="status" items="${roles}">
		                	 	<c:if test="${(status.index) % 3 == 0}">
		                	 	<tr><td>
		                	 	</c:if>
		                	 	<c:if test="${(status.index) % 3 != 0}">
		                	 	<td>
		                	 	</c:if>
		                	 	<form:checkbox path="rolesId" value="${role.id}"/><c:out value="${role.name}" />
		                	 	<c:if test="${(status.index) % 3 == 2}">
		                	 	</td></tr>
		                	 	</c:if>
		                	 	<c:if test="${(status.index) % 3 != 2}">
		                	 	</td>
		                	 	</c:if>
		                	 	<% if(index == n - 1 && index % 3 != 2) { %>
		                	 	</tr>
		                	 	<% } %>
		                	 	<% index ++; %>
		                	 </c:forEach>
	                	 </table>
	                </div>
	                
	                <div>
	                	<input type="submit" value="<fmt:message key='Save' />"/>&nbsp;
	                	<input type="button" onclick="document.location.href='<c:url value="/user/manage.o"/>'" value="<fmt:message key='Cancel' />"/>
	                </div>
	            </form:form>
	
	            <p><fmt:message key="UserComment" /></p>
	            
	        </div>
	
	    </div>
	
	    <script type="text/javascript">
	        document.getElementById('username').focus();
	    </script>
	
	</div>
</div>
<%@ include file="../common/foot.jsp" %>

</div>
	  
</body>
</html>
